<template>
  <div class="avue-sidebar">
    <logo></logo>
    <el-scrollbar view-style="font-weight: bold;height:100%;" :native="false">
      <div v-if="validatenull(menu)" class="avue-sidebar--tip">
        没有发现菜单
      </div>
      <el-menu
        unique-opened
        :default-active="nowTagValue"
        mode="vertical"
        :show-timeout="200"
        :collapse="keyCollapse"
      >
        <sidebar-item
          :menu="menu"
          :screen="screen"
          first
          :props="website.menu.props"
          :collapse="keyCollapse"
        ></sidebar-item>
      </el-menu>
    </el-scrollbar>
    <div style="padding:20px 10px;width: 100%;position:absolute;bottom:0px;color: #ffffff;">
      <el-row>
        <div>
          <div style="float:left;font-size: 12px;padding: 10px 0px">
            {{ this.repository.capacity }} / {{this.repository.maxCapacity}}
          </div>
          <div style="float: right"><el-button type="text" @click="open">免费扩容</el-button></div>
        </div>

      </el-row>
      <el-row>
        <el-progress style="color: black" :text-inside="true" :stroke-width="22" :color="(this.repository.percentage > 50) ?((this.repository.percentage > 80) ? '#ed3f14' : '#FFA500') :'#19be6b'" :percentage="this.repository.percentage"></el-progress>
      </el-row>
    </div>
  </div>
</template>

<script>
import { mapGetters,mapState } from "vuex";
import logo from "../logo";
import sidebarItem from "./sidebarItem";

export default {
  name: "sidebar",
  components: { sidebarItem, logo },
  data() {
    return {};
  },
  created() {
    this.$store.dispatch("GetMenu", { type: true, id: -1 }).then(data => {
      if (data.length === 0) return;
      this.$router.$avueRouter.formatRoutes(data, true);
    });
  },
  computed: {
    ...mapGetters(["repository","website", "menu", "tag", "keyCollapse", "screen"]),
    nowTagValue: function() {
      return this.$router.$avueRouter.getValue(this.$route);
    }
  },
  mounted() {},
  methods: {
    open() {
      this.$prompt('请输入邀请码', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        // inputPattern: /[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?/,
        inputErrorMessage: '邀请码格式不正确'
      }).then(({ value }) => {
        this.$message({
          type: 'success',
          message: '你的邀请码是: ' + value
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消输入'
        });
      });
    }
  }
};
</script>
<style lang="scss" scoped>
.scroll-container {
}


</style>
